<%@ taglib prefix="jaxson" uri="http://jaxson.org/base" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>jaxson test</title>
		
		<script type="text/javascript" src="jquery-131min.cjs"></script>
		
		<script language="javascript">
		//<jaxson:import>
		Base;
		org.jaxson.util.http.JsonServiceClient;
		//</jaxson:import>
		//ReverseAjaxBus.start();
		
		namespace( "mytest.somepackage");
		
		mytest.somepackage.MyTestClient = function(config){
			var that = {
				test: "foo"
			};
			
			inherits( "org.jaxson.util.http.JsonServiceClient", "mytest.somepackage.MyTestClient", that, config );
			
			that.addEvents([
				new TransactionalEvent( "test.event", "/jaxson/data.jsp1", true, true ),
				new TransactionalEvent( "another.event", "/jaxson/data1.jsp", true, true )
			]);
			
			that = that.createBindings(that);
			
			console.dir( that );
			
			return that;
		};
		
		var tc = new mytest.somepackage.MyTestClient();
		
		tc.addObserver( "test.event.succeeded", function(evt){
			console.log( evt );
		});
		
		tc.addObserver( "test.event.attempt", function(evt){
			console.log( "attempt 1" );
		});
		
		tc.addObserver( "test.event.attempted", function(evt){
			console.log( evt );
		});
		
		tc.addObserver( "test.event.failed", function(evt){
			console.log( "failed 1" );
		});		
		
		tc.addObserver( "test.event.failed", function(evt){
			console.log( "failed 2" );
			console.log( evt.statusCode );
		});
		
		//tc.txRequest("/jaxson/data1.jsp", "test.event", {rows: 5}, tc);
		//tc.txRequest("/jaxson/data.jsp", "test.event", {rows: 5}, tc);
		//tc.anotherEvent({});
		
		EventDispatcher.bindPattern(".*\.failed", function(e){
			console.log( "pattern handler called for ", e );	
		});
		
		tc.testEvent();
		tc.anotherEvent();
				
		//ReverseAjaxBus.start();
		</script>
	</head>

	<body>

	</body>
</html>
